package com.handpay.nocardpay.baselibrary.onlinemarket.presenter;

import android.content.Context;

import com.handpay.nocardpay.baselibrary.commbase.model.IBaseModel;
import com.handpay.nocardpay.baselibrary.commbase.model.bean.BaseErrorInfo;
import com.handpay.nocardpay.baselibrary.commbase.presenter.IBasePresenter;
import com.handpay.nocardpay.baselibrary.main.home.view.IHomeView;
import com.handpay.nocardpay.baselibrary.onlinemarket.model.MarketOrderDetailModel;
import com.handpay.nocardpay.baselibrary.onlinemarket.model.bean.MarketOrderDetailBean;
import com.handpay.nocardpay.baselibrary.onlinemarket.view.IOnlineMarketView;

import java.util.HashMap;

/**
 * Created by lyang on 2018/1/15.
 */

public class MarketOrderDetailPresenter implements IBasePresenter, IBaseModel.OnRequestFinishedListener<MarketOrderDetailBean> {
    private MarketOrderDetailModel mMarketOrderDetailModel;
    private IOnlineMarketView mOnlineMarketView;
    private Context mContext;

    public MarketOrderDetailPresenter(IOnlineMarketView onlineMarketView, Context context) {
        this.mMarketOrderDetailModel = new MarketOrderDetailModel(context);
        this.mOnlineMarketView = onlineMarketView;
        this.mContext = context;
    }


    @Override
    public void onDestory() {

    }

    public void getMarketOrderDetail(HashMap<String, Object> paramers, Class<MarketOrderDetailBean> clzz, boolean isShowLoading) {
        if (mOnlineMarketView != null) {
            if (isShowLoading) {
                mOnlineMarketView.showProgress();
            }
        }
        mMarketOrderDetailModel.request(paramers, clzz, this);
    }

    @Override
    public void onError(BaseErrorInfo baseErrorInfo) {
        if (mOnlineMarketView != null) {
            mOnlineMarketView.hideProgress();
            mOnlineMarketView.showErrorAlert(baseErrorInfo);
        }
    }

    @Override
    public void onSuccess(MarketOrderDetailBean response) {
        if (mOnlineMarketView != null) {
            mOnlineMarketView.hideProgress();
            mOnlineMarketView.onMarketOrderDetailSuccess(response);
        }
    }
}
